#!/bin/sh
#
# chkconfig: - 27 73
# description: Starts and stops the ISO-Server

# Source function library.
. /etc/rc.d/init.d/functions

# Avoid using root's TMPDIR
unset TMPDIR

RETVAL=0


start() {
	echo ""
	KIND="ISO-Server"
	echo -n $"Starting $KIND services: "
	python /opt/isoserver/iso-server.py silent &
	pid=$!
	echo $pid >/opt/isoserver/.pid
	echo $pid
	RETVAL=$?
	echo ""
	return $RETVAL
}	

stop() {
    echo ""
	KIND="ISO-Server"
	echo -n $"Shutting down $KIND services: "
	python /opt/isoserver/iso-server.py stop
	RETVAL=$?
	echo ""
	return $RETVAL
}	

restart() {
	stop
	start
}	

# Check that we can write to it... so non-root users stop here
[ -w /opt/isoserver/iso-server.config ] || exit 4

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
  	restart
	;;
  *)
	echo $"Usage: $0 {start|stop|restart}"
	exit 2
esac

exit $?
